
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include "Length.h"
#include "Volume.h"

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Length)
{
    TEST(should be able to check equality of same length unit)
    {
        ASSERT_TRUE(Dimension(100, FEET) == Dimension(100, FEET));
        ASSERT_TRUE(Dimension(30, YARD) == Dimension(30, YARD));
        ASSERT_TRUE(Dimension(5, MILE) == Dimension(5, MILE));
    }

    TEST(should be able to check inequality of different length unit)
    {
        ASSERT_TRUE(Dimension(10, FEET) != Dimension(10, YARD));
        ASSERT_TRUE(Dimension(25, YARD) != Dimension(25, MILE));
    }

    TEST(should be able to check inequality of differnt unit type)
    {
        ASSERT_TRUE(Dimension(1, FEET) != Dimension(1, OUNCE));
    }

    TEST(1 mile should be equal to 1760 yards)
    {
        ASSERT_EQ(Dimension(1, MILE), Dimension(1760, YARD));
    }

    TEST(1 yard should be equal to 3 feet)
    {
        ASSERT_EQ(Dimension(1, YARD), Dimension(3, FEET));
    }
    
    TEST(1 mile plus 1760 yard should be equal to 2 mile)
    {
        ASSERT_TRUE(Dimension(1, MILE) + Dimension(1760, YARD) == Dimension(2, MILE));
    }
    
    TEST(1 yard plus 1 feet should be equal to 4 feet)
    {
        ASSERT_TRUE(Dimension(1, YARD) + Dimension(1, FEET) == Dimension(4, FEET));
    }
    
    TEST(Should be able to throw exception upon addition between different unit type)
    {
        int hasException = 0;
        try
        {
            Dimension d = Dimension(1, MILE) + Dimension(1, OUNCE);
        }
        catch (int exception)
        {
            hasException = 1;
            ASSERT_EQ(exception, DIFFERENT_UNIT_TYPE);
        }
        ASSERT_EQ(hasException, 1);
    }
    
    TEST(Should be able to output 10 FEET as formatted string 3 YARD 1 FEET)
    {
        ASSERT_TRUE(Dimension(10, FEET).toString() == "3 YARD 1 FEET");
    }
    
    TEST(Should be able to output 5284 FEET as formatted string 1 MILE 1 YARD 1 FEET)
    {
        ASSERT_TRUE(Dimension(5284, FEET).toString() == "1 MILE 1 YARD 1 FEET");
    }
    
    TEST(Should be able to output 1761 YARD as formatted string 1 MILE 1 YARD)
    {
        ASSERT_TRUE(Dimension(1761, YARD).toString() == "1 MILE 1 YARD");
    }
    
    TEST(Should be able to output 5281 FEET as formatted string 1 MILE 1 FEET)
    {
        ASSERT_TRUE(Dimension(5281, FEET).toString() == "1 MILE 1 FEET");
    }
    
    TEST(Should be able to output 1 MILE as formatted string 5280 FEET)
    {
        ASSERT_TRUE(Dimension(1, MILE).toStringInSmallestUnit() == "5280 FEET");
    }
    
    TEST(Should be able to output 2 YARD as formatted string 6 FEET)
    {
        ASSERT_TRUE(Dimension(2, YARD).toStringInSmallestUnit() == "6 FEET");
    }
    
    TEST(Should be able to output 0 MILE as formatted string 0 FEET)
    {
        ASSERT_TRUE(Dimension(0, MILE).toString() == "0 FEET");
        ASSERT_TRUE(Dimension(0, MILE).toStringInSmallestUnit() == "0 FEET");
    }
};

